package com.dynamic.mybatis.demo.generator.mybatisplus;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.querys.DMQuery;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class Gennerator {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT&tinyInt1isBit=false";
        String username = "root";
        String password = "root";
        DataSourceConfig.Builder dscBuilder =  new DataSourceConfig.
             Builder(url, username, password);




        FastAutoGenerator.create(dscBuilder)
                .globalConfig(builder -> {
                    builder.author("baomidou") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .outputDir("D://mybatisplus-generator"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder
                            .parent("com.generator") // 设置父包名
                            .moduleName("test"); // 设置父包模块名

                })
                .strategyConfig(builder -> {
                    builder.addInclude("test") // 设置需要生成的表名
                            .addTablePrefix(); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
